package View.SetupScreens;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.JSpinner;
import javax.swing.JRadioButton;
import javax.swing.JButton;

import Model.Game;
import Model.Player;

/**
 * Constructs the number of human players setup screen.
 * Game has 4 total players at all times, this screen sets
 * the number of HUMAN players.
 * - Creates title label
 * - Creates radio buttons for choosing 1, 2, 3 or 4 human players
 * - On click to continue, sets each player in the game to isHuman(true)
 * 		or isHuman(false) and updates numberOfHumanPlayers in Game
 * @author Emily Curtin
 */

public class NumOfPlayersChooser extends JPanel {
	
	public ButtonGroup numPlayersButtonGroup;
	public JLabel numOfPlayersLabel;
	public JRadioButton rdbtn1Players;
	public JRadioButton rdbtn2Players;
	public JRadioButton rdbtn3Players;
	public JRadioButton rdbtn4Players;
	public JButton setNumberOfPlayers;
	
	private Player[] tempPlayers = new Player[4];
	
	/**
	 * Initializes, constructs, and sets parameters for all
	 * swing components. Includes actionlistener to set race
	 * parameters for players and call the next card.
	 * @param game - an instance of the main Game. The parameter is "final" so that the inner actionlistener class can access it.
	 */
	public NumOfPlayersChooser(final Game game) {
		setBackground(Color.BLACK);
		setLayout(null);
		setPreferredSize(new Dimension(1200,800));

		numOfPlayersLabel = new JLabel("NUMBER OF HUMAN PLAYERS");
		numOfPlayersLabel.setBounds(71, 36, 1057, 101);
		numOfPlayersLabel.setFont(new Font("Helvetica", Font.PLAIN, 70));
		numOfPlayersLabel.setForeground(new Color(204, 153, 0));
		
		rdbtn1Players = new JRadioButton("1 PLAYER");
		rdbtn1Players.setFont(new Font("Helvetica", Font.PLAIN, 60));
		rdbtn1Players.setForeground(new Color(204, 153, 0));
		rdbtn1Players.setBounds(411, 149, 393, 141);
		
		rdbtn2Players = new JRadioButton("2 PLAYERS");
		rdbtn2Players.setFont(new Font("Helvetica", Font.PLAIN, 60));
		rdbtn2Players.setForeground(new Color(204, 153, 0));
		rdbtn2Players.setBounds(411, 281, 393, 141);

		
		rdbtn3Players = new JRadioButton("3 PLAYERS");
		rdbtn3Players.setForeground(new Color(204, 153, 0));
		rdbtn3Players.setFont(new Font("Helvetica", Font.PLAIN, 60));
		rdbtn3Players.setBounds(411, 416, 393, 141);
		
		
		rdbtn4Players = new JRadioButton("4 PLAYERS");
		rdbtn4Players.setForeground(new Color(204, 153, 0));
		rdbtn4Players.setFont(new Font("Helvetica", Font.PLAIN, 60));
		rdbtn4Players.setBounds(411, 546, 393, 141);
		
		numPlayersButtonGroup = new ButtonGroup();
		numPlayersButtonGroup.add(rdbtn1Players);
		numPlayersButtonGroup.add(rdbtn2Players);
		numPlayersButtonGroup.add(rdbtn3Players);
		numPlayersButtonGroup.add(rdbtn4Players);

		
		setNumberOfPlayers = new JButton("SET THE NUMBER OF HUMAN PLAYERS");
		setNumberOfPlayers.setForeground(new Color(204, 153, 0));
		setNumberOfPlayers.setFont(new Font("Helvetica", Font.PLAIN, 41));
		setNumberOfPlayers.setBackground(Color.BLACK);
		setNumberOfPlayers.setBounds(199, 380, 849, 66);

		
		add(numOfPlayersLabel);
		add(rdbtn1Players);
		add(rdbtn2Players);
		add(rdbtn3Players);
		add(rdbtn4Players);
		add(setNumberOfPlayers);
	}
}
